package controller;

import model.container.CourseContainer;
import model.container.StudentContainer;
import model.container.TeacherContainer;
import persistency.writer.ContainerWriter;
import persistency.writer.CourseWriter;
import persistency.writer.Writer;
import persistency.writer.StudentWriter;
import persistency.writer.TeacherWriter;

public class ShutDownController {

	private static ShutDownController shutDownController;

	private ShutDownController() {
	}

	public static synchronized ShutDownController getInstance() {
		if (shutDownController == null) {
			shutDownController = new ShutDownController();
		}
		return shutDownController;
	}

	/**
	 * Stores the Data to the respective Data files
	 */
	public void saveData() {
		ContainerWriter courseWriter = new CourseWriter();
		courseWriter.write(CourseContainer.getInstance().getCourses());
		ContainerWriter teacherWriter = new TeacherWriter();
		teacherWriter.write(TeacherContainer.getInstance().getTeachers());
		ContainerWriter studentWriter = new StudentWriter();
		studentWriter.write(StudentContainer.getInstance().getStudents());
	}
}

